﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microhard.Core.DBUtility;
using Microhard.WarehouseInsp.Buz.Validator;
using Microhard.WarehouseInsp.Buz.BuzEnum;
using Microhard.Core.Extensions;
using System.ComponentModel.DataAnnotations;

namespace Microhard.WarehouseInsp.Buz.Models
{
    [FluentValidation.Attributes.Validator(typeof(SupProjectModelValidator))]
    public class SupProjectModel : BasePermissionModel
    {
        public SupProjectModel()
        {
            this.PrjEndTime = this.PrjStartTime = DateTime.Now;
        }

        [ModelPKID]
        public Guid ProjectID { set; get; }
        public string BorrowerID { set; get; }
        public string BorrowerName { set; get; }
        public string MortgagorID { set; get; }
        public string MortgagorName { set; get; }
        [DataType(DataType.Currency)]
        public decimal Credit { set; get; }
        [DataType(DataType.Currency)]
        public decimal Guarantee { set; get; }
        public Guid PMID { set; get; }
        public string PMName { set; get; }
        public DateTime PrjStartTime { set; get; }
        public DateTime PrjEndTime { set; get; }
        public decimal SupervisionFee { set; get; }
        public decimal Rent { set; get; }
        public decimal SupInsuranceCharge { set; get; }
        public decimal ProtyInsuranceCharge { set; get; }
        public string PedgeeCompanyName { set; get; }
        public string PedgeeContactor { set; get; }
        public string PedgeeContactorPhone { set; get; }
        public DateTime CreateTime { set; get; }
        public DateTime UpdateTime { set; get; }
        public int Status { set; get; }
        public string Code { set; get; }
        public string Name { set; get; }
        public string ApplierID { set; get; }
        public string ApplierName { set; get; }

        public decimal WarnAmount { set; get; }
        public decimal Guardline { set; get; }
        public decimal Worth { set; get; }
        public string StartEndDate
        {
            get
            {
                return this.PrjStartTime.ToString("yyyy-MM-dd") + "至" + this.PrjEndTime.ToString("yyyy-MM-dd");
            }
        }
        public string StatusDisplay
        {
            get
            {
                var um = (PrjStatus)Enum.Parse(typeof(PrjStatus), this.Status.ToString());
                return um.GetDisplayText();
            }
        }
        public Guid FirstSupervisionDetailID { set; get; }

        public List<AttachmentModel> Files { set; get; }
        public List<SupervisionDetailModel> Supervisions { set; get; }
        public List<PledgePlanInRecordsModel> Pledges { set; get; }

        public string ApproverName { set; get; }
        public string ApproverID { set; get; }
        public Guid ProtalEmpID { set; get; }
        public string ProtalEmpName { set; get; }

        public string MortgagorFRName { set; get; }
        public string MortgagorFRIdentityNo { set; get; }
        public string MortgagorFRCellphone { set; get; }

        public string MortgagorContractorName { set; get; }
        public string MortgagorContractorCellphone { set; get; }
        public double Rate { set; get; }
        public Guid PrjType { set; get; }
        [ModelReadTxtFromoCache(IDFieldName = "PrjType")]
        public string PrjTypeDisplay { set; get; }
        public string SalerID { set; get; }
        public string SalerName { set; get; }
    }
}
